package com.rocpenghua.design.memento;

/**
 * @author pengp
 * @date 2023年02月23日 11:31
 */
public class MainTest {
    public static void main(String[] args) {
        Originator originator = new Originator();
        CareTaker careTaker = new CareTaker();
        originator.setState("State #1");
        originator.setState("State #2");
        careTaker.add(originator.saveStateToMemento());
        originator.setState("State #3");
        careTaker.add(originator.saveStateToMemento());
        originator.setState("State #4");

        System.out.println("Current State: " + originator.getState());
        System.out.println("First saved State: " + originator.getStateFromMemento(careTaker.get(0)));
        System.out.println("Second saved State: " + originator.getStateFromMemento(careTaker.get(1)));
    }
}
/**
 * Current State: State #4
 * First saved State: State #2
 * Second saved State: State #3
 */